﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="XiTongDic.aspx.cs" Inherits="PropertyAppraisal.SystemManage.XiTongDic" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>

    <link rel="stylesheet" type="text/css" href="../easyui/easyui/1.3.2/themes/default/easyui.css" />
    <link rel="stylesheet" type="/text/css" href="../easyui/easyui/1.3.2/themes/icon.css" />
    <script src="../easyui/easyui/1.3.2/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="../easyui/easyui/1.3.2/jquery.easyui.min.js"></script>
    <script src="../easyui/easyui/1.3.2/locale/easyui-lang-zh_CN.js"></script>
    <script src="../easyui/easyui/1.3.2/easyloader.js"></script>
    <script>
        
    </script>
</head>
<body>
        <iframe width="0" height="0" src="../SessionKeeper.aspx"></iframe>   
    <table id="ta" title="字典列表" style="width: 1190px; height: 600px" data-options="
				rownumbers:true,
				singleSelect:true,
				autoRowHeight:false,
				pagination:true,
				pageSize:10">
        <thead>
            <tr>
                <th field="DicId" width="200" align="center">字典编号</th>
                <th field="DicName" width="400" align="center">字典名称</th>
                <th field="DicType" width="200" align="center">字典类型</th>
                <th field="cao" width="300" align="center">操作</th>
            </tr>
        </thead>
    </table>


    <script type="text/javascript">

        //删除字典
        function DelDictionary(Dictionary_Number) {
            $.messager.defaults = { ok: "是", cancel: "否" };
            $.messager.confirm('删除提示', 'Are you sure about the deletion?', function (obj) {

                if (obj) {
                    $.ajax({
                        type: "post", //要用post方式                 
                        url: "XiTongDic.aspx/DelDictionary",//方法所在页面和方法名
                        data: "{'Dictionary_Number':'" + Dictionary_Number + "'}",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (data) {
                            var json = eval("(" + data.d + ")");
                            if (json) {
                                $.messager.alert('Success', 'Yes');
                            }
                        }
                    })
                }
                else {
                    $.messager.alert('Error', 'No');
                }
            })
        }

        //跳转到新增员工
        function addemp() {
            parent.addTab("新增员工信息", "/SystemManage/XiTongAddEmp.aspx", "", true);
        }

        //表格
        function getData() {
            var rows = [];
            $.ajax({
                type: "post", //要用post方式                 
                url: "XiTongDic.aspx/showDic",//方法所在页面和方法名
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                async: false,
                success: function (result) {
                    var json = eval("(" + result.d + ")");
                    for (var i = 0; i < json.length; i++) {
                        rows.push({
                            DicId: json[i].Dictionary_Number,
                            DicName: json[i].dictionary_Name,
                            DicType: json[i].dictionary_Type,
                            cao: '<input type="button" id="delDictionary" onclick="DelDictionary(' + json[i].Dictionary_Number + ')" value="删除"/><input type="button" value="修改" onclick="EditDictionary(' + json[i].Dictionary_Number + ')"/><input type="button" value="停用"/>',
                        });
                    }
                }
            })
            return rows;
        }

        function pagerFilter(data) {
            if (typeof data.length == 'number' && typeof data.splice == 'function') {	// is array
                data = {
                    total: data.length,
                    rows: data
                }
            }
            var dg = $(this);
            var opts = dg.datagrid('options');
            var pager = dg.datagrid('getPager');
            pager.pagination({
                onSelectPage: function (pageNum, pageSize) {
                    opts.pageNumber = pageNum;
                    opts.pageSize = pageSize;
                    pager.pagination('refresh', {
                        pageNumber: pageNum,
                        pageSize: pageSize
                    });
                    dg.datagrid('loadData', data);
                },
                onRefresh: function (pageNum, pageSize) {
                    $('#ta').datagrid({ loadFilter: pagerFilter }).datagrid('loadData', getData());
                }
            });
            if (!data.originalRows) {
                data.originalRows = (data.rows);
            }
            var start = (opts.pageNumber - 1) * parseInt(opts.pageSize);
            var end = start + parseInt(opts.pageSize);
            data.rows = (data.originalRows.slice(start, end));
            return data;
        }

        //修改
        function EditDictionary(obj) {
            parent.addTab("字典编辑", "/SystemManage/DictionaryEdit.aspx?Dictionary_Number=" + obj, "icon-chart-organisation", true);
        }


        $(function () {
            $('#ta').datagrid({ loadFilter: pagerFilter }).datagrid('loadData', getData());
        });
    </script>
</body>
</html>
